OpenCV
ImageTransformer
- Python
- Scala
from synapse.ml.opencv import *
from pyspark.sql.types import FloatType
# images = (spark.read.format("image")
# .option("dropInvalid", True)
# .load("wasbs://publicwasb@mmlspark.blob.core.windows.net/explainers/images/david-lusvardi-dWcUncxocQY-unsplash.jpg"))
it = (ImageTransformer(inputCol="image", outputCol="features")
.resize(224, True)
.centerCrop(height=224, width=224)
.normalize(mean=[0.485, 0.456, 0.406], std=[0.229, 0.224, 0.225], color_scale_factor = 1/255)
.setTensorElementType(FloatType()))
# it.transform(images).show()
import com.microsoft.azure.synapse.ml.opencv._
val images = (spark.read.format("image")
.option("dropInvalid", true)
.load("wasbs://publicwasb@mmlspark.blob.core.windows.net/explainers/images/david-lusvardi-dWcUncxocQY-unsplash.jpg"))
val it = (new ImageTransformer()
.setOutputCol("out")
.resize(height = 15, width = 10))
it.transform(images).show()
Python API: ImageTransformer | Scala API: ImageTransformer | Source: ImageTransformer |
ImageSetAugmenter
- Python
- Scala
from synapse.ml.opencv import *
# images = (spark.read.format("image")
# .option("dropInvalid", True)
# .load("wasbs://publicwasb@mmlspark.blob.core.windows.net/explainers/images/david-lusvardi-dWcUncxocQY-unsplash.jpg"))
isa = (ImageSetAugmenter()
.setInputCol("image")
.setOutputCol("augmented")
.setFlipLeftRight(True)
.setFlipUpDown(True))
# it.transform(images).show()
import com.microsoft.azure.synapse.ml.opencv._
val images = (spark.read.format("image")
.option("dropInvalid", true)
.load("wasbs://publicwasb@mmlspark.blob.core.windows.net/explainers/images/david-lusvardi-dWcUncxocQY-unsplash.jpg"))
val isa = (new ImageSetAugmenter()
.setInputCol("image")
.setOutputCol("augmented")
.setFlipLeftRight(true)
.setFlipUpDown(true))
isa.transform(images).show()
Python API: ImageSetAugmenter | Scala API: ImageSetAugmenter | Source: ImageSetAugmenter |